local sk__sanfen = fk.CreateSkill {

  name = "sk__sanfen",

  tags = {  },

}



sk__sanfen:addEffect("active", {
  name = "sk__sanfen",
  anim_type = "control",
  card_num = 0,
  target_num = 2,
  prompt = function(self, player, selected_cards, selected_targets)
    if #selected_targets == 0 then
      return "#sk__sanfen0"
    elseif #selected_targets == 1 then
      return "#sk__sanfen1:"..selected_targets[1].id
    elseif #selected_targets == 2 then
      return "#sk__sanfen2:"..selected_targets[1].id..":"..selected_targets[2].id
    end
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(sk__sanfen.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, player, to_select, selected, selected_cards)
    return #selected < 2 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target1 = effect.tos[1]
    local target2 = effect.tos[2]
    local yes = false
    local use = room:askForUseCard(target1, "slash", "slash",
      "#sk__sanfen-use::"..target2.id, true, {exclusive_targets = {target2.id}})
    if use then
      room:useCard(use)
    else
      yes = true
    end
    if not target2.dead then
      room:delay(800)
      use = room:askForUseCard(target2, "slash", "slash",
        "#sk__sanfen-use::"..player.id, true, {exclusive_targets = {player.id}})
      if use then
        room:useCard(use)
      else
        yes = true
      end
    else
      yes = true
    end
    if not player.dead and not target1.dead and not player:isProhibited(target1, Fk:cloneCard("slash")) then
      room:delay(800)
      room:useVirtualCard("slash", nil, player, target1, sk__sanfen.name, true)
    else
      yes = true
    end
    if yes then
      for _, p in ipairs({target1, target2}) do
        if not player.dead and not p.dead and not p:isNude() then
          room:delay(800)
          local card = room:askForCardChosen(player, p, "he", sk__sanfen.name, "#sk__sanfen-discard::"..p.id)
          room:throwCard({card}, sk__sanfen.name, p, player)
        end
      end
    end
  end
})

return sk__sanfen